﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Windows.Forms;

namespace balace_project_new
{
    class UpdateDatagrid
    {        
        public void Update_dtgDetails(DataGridView dtg, Data.revData recvDt)
        {
            int n = dtg.Rows.Count-1;     
            Data Dt = new Data();
            dtg.Rows[n].Cells[0].Value = n.ToString();
            dtg.Rows[n].Cells[1].Value = recvDt.BalanceID;
            dtg.Rows[n].Cells[2].Value = recvDt.Sequence;
            dtg.Rows[n].Cells[3].Value = recvDt.Weight.ToString();
            dtg.Rows[n].Cells[4].Value = recvDt.WeightErr.ToString();
            dtg.Rows[n].Cells[5].Value = recvDt.Err.ToString();
            dtg.Rows[n].Cells[6].Value = recvDt.Quality;
            dtg.Rows[n].Cells[7].Value = recvDt.Time.ToString();            
        }
        public void Update_dtgStatic(DataGridView dtg, Data.revData recvDt)
        {
            Data Dt = new Data();
            int n = int.Parse(recvDt.BalanceID) - 1;            
            dtg.Rows[n].Cells[1].Value = recvDt.Sequence.ToString();
            dtg.Rows[n].Cells[2].Value = recvDt.Weight.ToString();
            dtg.Rows[n].Cells[3].Value = recvDt.WeightErr.ToString();
            dtg.Rows[n].Cells[4].Value = recvDt.Err.ToString();
            dtg.Rows[n].Cells[5].Value = recvDt.Quality;
            dtg.Rows[n].Cells[6].Value = recvDt.Time.ToString();            
        }      
        public void Update_dtgBalance(DataGridView dtg, Data.revData recvDt)
        {
            int n = dtg.Rows.Count - 1;
            dtg.Rows[n].Cells["Lần Cân"].Value = recvDt.Sequence.ToString();
            dtg.Rows[n].Cells["Khối Lượng (g)"].Value = recvDt.Weight.ToString();
            dtg.Rows[n].Cells["Sai Số (g)"].Value = recvDt.WeightErr.ToString();
            dtg.Rows[n].Cells["Sai Số (%)"].Value = recvDt.Err.ToString();
            dtg.Rows[n].Cells["Chất Lượng"].Value = recvDt.Quality;
            dtg.Rows[n].Cells["Thời gian"].Value = recvDt.Time.ToString();
        }

        #region Init DataGridViews
        public void Init_dtgDetails(DataGridView dtg)
        {
            balance_schemaDataSetTableAdapters.recvdataTableAdapter adt = new balance_schemaDataSetTableAdapters.recvdataTableAdapter();
            dtg.DataSource = adt.GetData();
            dtg.Columns["Địa Chỉ"].Visible = false;
            dtg.Columns["STT"].AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
            dtg.Columns["Cân"].AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
            dtg.Columns["Chất Lượng"].AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
        }
        public void Init_dtgStatic(DataGridView dtg, Data dt)
        {
            dt.Init_StructData();
            dtg.BringToFront();
            int Rows = 17;
            for (int i = 0; i < Rows; i++)
            {
                dtg.Rows.Add();
                dtg.Rows[i].Cells[0].Value = (i + 1).ToString();
                dtg.Rows[i].Cells[1].Value = dt.arrRevData[i].Sequence.ToString();
                dtg.Rows[i].Cells[2].Value = dt.arrRevData[i].Weight.ToString();
                dtg.Rows[i].Cells[3].Value = dt.arrRevData[i].WeightErr.ToString();
                dtg.Rows[i].Cells[4].Value = dt.arrRevData[i].Err.ToString();
                dtg.Rows[i].Cells[5].Value = dt.arrRevData[i].Quality;
                dtg.Rows[i].Cells[6].Value = dt.arrRevData[i].Time.ToString();
            }
        }
        public void Init_dtgBalance01(DataGridView dtg) //, balance_schemaDataSet.recvdataDataTable dtb)
        {
            balance_schemaDataSetTableAdapters.recvdataTableAdapter adt = new balance_schemaDataSetTableAdapters.recvdataTableAdapter();
            dtg.DataSource = adt.GetDataBy01();
            dtg.Columns["STT"].Visible = false;
            dtg.Columns["Địa Chỉ"].Visible = false;
            dtg.Columns["Cân"].Visible = false;
        }
        public void Init_dtgBalance02(DataGridView dtg) //, balance_schemaDataSet.recvdataDataTable dtb)
        {
            balance_schemaDataSetTableAdapters.recvdataTableAdapter adt = new balance_schemaDataSetTableAdapters.recvdataTableAdapter();
            dtg.DataSource = adt.GetDataBy02();
            dtg.Columns["STT"].Visible = false;
            dtg.Columns["Địa Chỉ"].Visible = false;
            dtg.Columns["Cân"].Visible = false;
        }
        public void Init_dtgBalance03(DataGridView dtg) //, balance_schemaDataSet.recvdataDataTable dtb)
        {
            balance_schemaDataSetTableAdapters.recvdataTableAdapter adt = new balance_schemaDataSetTableAdapters.recvdataTableAdapter();
            dtg.DataSource = adt.GetDataBy03();
            dtg.Columns["STT"].Visible = false;
            dtg.Columns["Địa Chỉ"].Visible = false;
            dtg.Columns["Cân"].Visible = false;
        }
        public void Init_dtgBalance04(DataGridView dtg) //, balance_schemaDataSet.recvdataDataTable dtb)
        {
            balance_schemaDataSetTableAdapters.recvdataTableAdapter adt = new balance_schemaDataSetTableAdapters.recvdataTableAdapter();
            dtg.DataSource = adt.GetDataBy04();
            dtg.Columns["STT"].Visible = false;
            dtg.Columns["Địa Chỉ"].Visible = false;
            dtg.Columns["Cân"].Visible = false;
        }
        public void Init_dtgBalance05(DataGridView dtg) //, balance_schemaDataSet.recvdataDataTable dtb)
        {
            balance_schemaDataSetTableAdapters.recvdataTableAdapter adt = new balance_schemaDataSetTableAdapters.recvdataTableAdapter();
            dtg.DataSource = adt.GetDataBy05();
            dtg.Columns["STT"].Visible = false;
            dtg.Columns["Địa Chỉ"].Visible = false;
            dtg.Columns["Cân"].Visible = false;
        }
        public void Init_dtgBalance06(DataGridView dtg) //, balance_schemaDataSet.recvdataDataTable dtb)
        {
            balance_schemaDataSetTableAdapters.recvdataTableAdapter adt = new balance_schemaDataSetTableAdapters.recvdataTableAdapter();
            dtg.DataSource = adt.GetDataBy06();
            dtg.Columns["STT"].Visible = false;
            dtg.Columns["Địa Chỉ"].Visible = false;
            dtg.Columns["Cân"].Visible = false;
        }
        public void Init_dtgBalance07(DataGridView dtg) //, balance_schemaDataSet.recvdataDataTable dtb)
        {
            balance_schemaDataSetTableAdapters.recvdataTableAdapter adt = new balance_schemaDataSetTableAdapters.recvdataTableAdapter();
            dtg.DataSource = adt.GetDataBy07();
            dtg.Columns["STT"].Visible = false;
            dtg.Columns["Địa Chỉ"].Visible = false;
            dtg.Columns["Cân"].Visible = false;
        }
        public void Init_dtgBalance08(DataGridView dtg) //, balance_schemaDataSet.recvdataDataTable dtb)
        {
            balance_schemaDataSetTableAdapters.recvdataTableAdapter adt = new balance_schemaDataSetTableAdapters.recvdataTableAdapter();
            dtg.DataSource = adt.GetDataBy08();
            dtg.Columns["STT"].Visible = false;
            dtg.Columns["Địa Chỉ"].Visible = false;
            dtg.Columns["Cân"].Visible = false;
        }
        public void Init_dtgBalance09(DataGridView dtg) //, balance_schemaDataSet.recvdataDataTable dtb)
        {
            balance_schemaDataSetTableAdapters.recvdataTableAdapter adt = new balance_schemaDataSetTableAdapters.recvdataTableAdapter();
            dtg.DataSource = adt.GetDataBy09();
            dtg.Columns["STT"].Visible = false;
            dtg.Columns["Địa Chỉ"].Visible = false;
            dtg.Columns["Cân"].Visible = false;
        }
        public void Init_dtgBalance10(DataGridView dtg) //, balance_schemaDataSet.recvdataDataTable dtb)
        {
            balance_schemaDataSetTableAdapters.recvdataTableAdapter adt = new balance_schemaDataSetTableAdapters.recvdataTableAdapter();
            dtg.DataSource = adt.GetDataBy10();
            dtg.Columns["STT"].Visible = false;
            dtg.Columns["Địa Chỉ"].Visible = false;
            dtg.Columns["Cân"].Visible = false;
        }
        public void Init_dtgBalance11(DataGridView dtg) //, balance_schemaDataSet.recvdataDataTable dtb)
        {
            balance_schemaDataSetTableAdapters.recvdataTableAdapter adt = new balance_schemaDataSetTableAdapters.recvdataTableAdapter();
            dtg.DataSource = adt.GetDataBy11();
            dtg.Columns["STT"].Visible = false;
            dtg.Columns["Địa Chỉ"].Visible = false;
            dtg.Columns["Cân"].Visible = false;
        }
        public void Init_dtgBalance12(DataGridView dtg) //, balance_schemaDataSet.recvdataDataTable dtb)
        {
            balance_schemaDataSetTableAdapters.recvdataTableAdapter adt = new balance_schemaDataSetTableAdapters.recvdataTableAdapter();
            dtg.DataSource = adt.GetDataBy12();
            dtg.Columns["STT"].Visible = false;
            dtg.Columns["Địa Chỉ"].Visible = false;
            dtg.Columns["Cân"].Visible = false;
        }
        public void Init_dtgBalance13(DataGridView dtg) //, balance_schemaDataSet.recvdataDataTable dtb)
        {
            balance_schemaDataSetTableAdapters.recvdataTableAdapter adt = new balance_schemaDataSetTableAdapters.recvdataTableAdapter();
            dtg.DataSource = adt.GetDataBy13();
            dtg.Columns["STT"].Visible = false;
            dtg.Columns["Địa Chỉ"].Visible = false;
            dtg.Columns["Cân"].Visible = false;
        }
        public void Init_dtgBalance14(DataGridView dtg) //, balance_schemaDataSet.recvdataDataTable dtb)
        {
            balance_schemaDataSetTableAdapters.recvdataTableAdapter adt = new balance_schemaDataSetTableAdapters.recvdataTableAdapter();
            dtg.DataSource = adt.GetDataBy14();
            dtg.Columns["STT"].Visible = false;
            dtg.Columns["Địa Chỉ"].Visible = false;
            dtg.Columns["Cân"].Visible = false;
        }
        public void Init_dtgBalance15(DataGridView dtg) //, balance_schemaDataSet.recvdataDataTable dtb)
        {
            balance_schemaDataSetTableAdapters.recvdataTableAdapter adt = new balance_schemaDataSetTableAdapters.recvdataTableAdapter();
            dtg.DataSource = adt.GetDataBy15();
            dtg.Columns["STT"].Visible = false;
            dtg.Columns["Địa Chỉ"].Visible = false;
            dtg.Columns["Cân"].Visible = false;
        }
        public void Init_dtgBalance16(DataGridView dtg) //, balance_schemaDataSet.recvdataDataTable dtb)
        {
            balance_schemaDataSetTableAdapters.recvdataTableAdapter adt = new balance_schemaDataSetTableAdapters.recvdataTableAdapter();
            dtg.DataSource = adt.GetDataBy16();
            dtg.Columns["STT"].Visible = false;
            dtg.Columns["Địa Chỉ"].Visible = false;
            dtg.Columns["Cân"].Visible = false;
        }
        public void Init_dtgBalance17(DataGridView dtg) //, balance_schemaDataSet.recvdataDataTable dtb)
        {
            balance_schemaDataSetTableAdapters.recvdataTableAdapter adt = new balance_schemaDataSetTableAdapters.recvdataTableAdapter();
            dtg.DataSource = adt.GetDataBy17();
            dtg.Columns["STT"].Visible = false;
            dtg.Columns["Địa Chỉ"].Visible = false;
            dtg.Columns["Cân"].Visible = false;
        }
        #endregion Init DataGridViews
    }
}
